package cn.vcjf.weapp.api.goods.controller;


import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.ResponseBody;
import cn.vcjf.weapp.common.web.TableResult;
import com.baomidou.mybatisplus.plugins.Page;
import cn.vcjf.weapp.api.goods.entity.GoodsInfo;
import cn.vcjf.weapp.api.goods.service.GoodsInfoService;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 商品信息
 * </p>
 *
 * @author zhengzihang
 * @since 2018-09-25
 */
@Controller
@RequestMapping("/goods/goodsInfo")
public class GoodsInfoController {
	@Resource
	private GoodsInfoService goodsInfoService;
	/**
	 * 获取商品参数
	 * @param goodsInfo
	 * @return
	 */
	@RequestMapping("/findGoodsProperties")
	@ResponseBody
	public TableResult findGoodsProperties(GoodsInfo goodsInfo) {

		GoodsInfo result = goodsInfoService.selectById(goodsInfo.getId());


		return TableResult.OKResult(result);
	}

	/**
	 * 获取商品详情
	 * @param goodsInfo
	 * @return
	 */
	@RequestMapping("/findGoodsDetailInfo")
	@ResponseBody
	public TableResult findGoodsDetailInfo(GoodsInfo goodsInfo) {

		GoodsInfo result = goodsInfoService.selectGoodDetailInfo(goodsInfo);

		return TableResult.OKResult(result);
	}

	/**
	 * 热门商品(人气推荐)
	 *
	 * @param goodsInfo
	 * @return
	 */
	@RequestMapping("/findHotGoodList")
	@ResponseBody
	public TableResult findHotGoodList(GoodsInfo goodsInfo) {

		Page<GoodsInfo> page = goodsInfo.getPageInfo();

		page = goodsInfoService.findHotGoodList(page, goodsInfo);

		return TableResult.OKResult(page);

	}

	/**获取商品列表*/
	@RequestMapping("/findGoodsInfoList")
	@ResponseBody
	public TableResult findGoodsInfoList(GoodsInfo goodsInfo) {

		Page<GoodsInfo> page = goodsInfo.getPageInfo();

		page = goodsInfoService.selectGoodsInfoPage(page, goodsInfo);

		return TableResult.OKResult(page);

	}
	/**
	 * 商品详情的推荐列表
	 *
	 * @param goodsInfo
	 * @return
	 */
	@RequestMapping("/findRecommendedGoodList")
	@ResponseBody
	public TableResult findRecommendedGoodList(GoodsInfo goodsInfo) {

		Page<GoodsInfo> page = goodsInfo.getPageInfo();

		page = goodsInfoService.findRecommendedGoodList(page, goodsInfo);

		return TableResult.OKResult(page);

	}
}
